﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text.RegularExpressions;
using System.Web;

namespace MovingChame.Web.Helpers
{
    public static class EmailHelper
    {
        private const string from = "vuphuong245@gmail.com";

        public static void SendEmail(string to, string cc, string bcc, string subject, string body)
        {
            using (var client = new SmtpClient())
            {
                using (var message = new MailMessage(from, to))
                {
                    message.Subject = subject;
                    message.Body = body;
                    message.IsBodyHtml = true;

                    client.Send(message);
                }
            }
        }

        public static string createResetPasswordEmail(string username, string token)
        {
            var result = string.Format(@"
<p>Dear <b>{0}</b>,</p><br />
<p>We have just received a request for reseting the password for your account.</p>
<p>Please use this token to reset the password. This token will be exprired in 24 hours.</p>
<h1>{1}</h1>
<br />
<p>Regards,</p>
<p>Chameleons Team</p>", username, token);
            return result;
        }

        public static bool ValidateEmail(string email)
        {
            try
            {
                MailAddress mailAddress = new MailAddress(email);
                return true;
            }
            catch (FormatException)
            {
                return false;
            }
        }
    }
}